//
//  SSThirdLoginView.m
//  textDemo
//
//  Created by Esther on 2017/2/18.
//  Copyright © 2017年 Esther. All rights reserved.
//

#import "SSThirdLoginView.h"

@interface SSThirdLoginView()
@property(nonatomic, strong) UILabel *lineLabel;                // 分割线
@property(nonatomic, strong) UIButton *qqLoginButton;           // QQ登录
@property(nonatomic, strong) UIButton *wxLoginButton;           // 微信登录
@property(nonatomic, strong) UIButton *sinaLoginButton;         // 微博登录
@property(nonatomic, strong) UILabel *oneLoginLabel;            // 一键登录Label

@end

@implementation SSThirdLoginView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    [self addSubview:self.lineLabel];
    [self addSubview:self.oneLoginLabel];
    //快捷登录
    [self addSubview:self.qqLoginButton];
    [self addSubview:self.wxLoginButton];
    [self addSubview:self.sinaLoginButton];
    
    #pragma mark - 约束
    __weak typeof (self) weakSelf = self;
    [_oneLoginLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80.0, 20.0));
        make.centerX.equalTo(weakSelf.mas_centerX);
        make.top.equalTo(weakSelf.mas_top).offset(57);
    }];
    
    [_lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.oneLoginLabel.mas_centerY);
        make.height.mas_equalTo(1);
        make.left.equalTo(weakSelf.mas_left).offset(16);
        make.right.equalTo(weakSelf.mas_right).offset(-16);
    }];
    
    
    [_wxLoginButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.oneLoginLabel.mas_bottom).offset(20);
        make.size.mas_equalTo(CGSizeMake(45, 45));
        make.centerX.equalTo(weakSelf.mas_centerX);
    }];
    
    [_qqLoginButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.oneLoginLabel.mas_bottom).offset(20);
        make.size.mas_equalTo(CGSizeMake(45, 45));
        make.right.equalTo(weakSelf.wxLoginButton.mas_left).offset(- ([UIScreen ss_screenWidth] - 135) / 4);
        
    }];
    
    [_sinaLoginButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.oneLoginLabel.mas_bottom).offset(20);
        make.size.mas_equalTo(CGSizeMake(45, 45));
        make.left.equalTo(weakSelf.wxLoginButton.mas_right).offset(([UIScreen ss_screenWidth] - 135) / 4);
    }];

    
}


#pragma mark -
#pragma mark - 监听方法
- (void)qqLoginMethod{
    if (self.qqLoginBlock) {
        self.qqLoginBlock();
    }
}

#pragma mark -
#pragma mark - 懒加载

- (UIButton *)qqLoginButton{
    if (!_qqLoginButton) {
        _qqLoginButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_qqLoginButton setImage:[UIImage imageNamed:@"登录界面qq登陆"] forState:UIControlStateNormal];
        [_qqLoginButton addTarget:self action:@selector(qqLoginMethod) forControlEvents:(UIControlEventTouchUpInside)];
        
        
    }
    return _qqLoginButton;
}

- (UIButton *)wxLoginButton{
    if (!_wxLoginButton) {
        _wxLoginButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_wxLoginButton setImage:[UIImage imageNamed:@"登录界面微信登录"] forState:UIControlStateNormal];
        
    }
    return _wxLoginButton;
}

- (UIButton *)sinaLoginButton{
    if (!_sinaLoginButton) {
        _sinaLoginButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_sinaLoginButton setImage:[UIImage imageNamed:@"登陆界面微博登录"] forState:UIControlStateNormal];
        
        
    }
    return _sinaLoginButton;
}
- (UILabel *)oneLoginLabel{
    if (!_oneLoginLabel) {
        _oneLoginLabel = [[UILabel alloc] init];
        _oneLoginLabel.text = @"一键登录";
        _oneLoginLabel.textColor = [UIColor ss_colorWithRed:190 green:190 blue:190];
        _oneLoginLabel.backgroundColor = [UIColor ss_colorWithRed:242 green:242 blue:242];
        _oneLoginLabel.textAlignment = NSTextAlignmentCenter;
        _oneLoginLabel.font = [UIFont systemFontOfSize:16.0];
    }
    return _oneLoginLabel;
}
- (UILabel *)lineLabel{
    if (!_lineLabel) {
        _lineLabel = [[UILabel alloc] init];
        _lineLabel.backgroundColor = [UIColor ss_colorWithRed:190 green:190 blue:190];
    }
    return _lineLabel;
}


@end
